<template>
<!-- 活动列表 -->
  <div>
     <TopFilter
      :list="topFilterInit"
      :cols="3"
      :collapse=false
      @filterChange="changeHandle"
      @onCollapse="collapseHandle"
    ></TopFilter>
    <FilterTable
      ref="table"
      height='270'
      :columns="columns"
      :fetchapi="fetchParams"
      :params="flterValue"
      :datakey="'records'"
      :onColumnsChange="columns => this.columns = columns"
      :onRowSelectChange="selectChange"
    >
    </FilterTable>
   <div class="dialogBottmView">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button @click="saveDialog"  type="primary">保 存</el-button>
    </div>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
export default {
  mixins: [dictionary],
  data() {
    return {
      topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      columns: this.creatHeader(),
      fetchParams: null, //ipa 接口
      selectData:[]
    };
  },
  mounted() {
     this.BaseTable = this.$refs.table.$refs.pageTable;
    //请求接口进行赋值，自己写吧
  },
  methods: {
    //搜索数据
    topFilterInitFun() {
      return [
        { type: 'INPUT',  label: '品牌', fieldName: 'field0',  placeholder: '请选择', initialValue: ''},
        { type: 'INPUT',  label: '车型', fieldName: 'field1',  placeholder: '请选择', initialValue: ''}
     ];
    },//搜索获取数据
    changeHandle(val) {
      this.flterValue = val;
      console.log(val);
    },
     //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
       { title: '品牌', dataIndex: 'field3', sorter: true},
       { title: '车型', dataIndex: 'field4', sorter: true }
      ]
    },
    //复选框选择
    selectChange(data){
      this.selectData=data
    },
      //保存
    saveDialog(){
      this.$refs.infoActivityDialog.SUBMIT_FORM()
    },
    //取消操作
    closeDialog() {
      this.$emit('close', this.selectData);
    },
    
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    }
  }
}
</script>